package other.mvvm.activity.src.app_package.guide

import com.android.tools.idea.wizard.template.ModuleTemplateData
import com.android.tools.idea.wizard.template.RecipeExecutor
import com.android.tools.idea.wizard.template.impl.activities.common.generateManifest
import other.mvvm.activity.res.layout.guide.guideActivityXml

fun RecipeExecutor.guideActivityRecipe(
        moduleData: ModuleTemplateData,
        activityClass: String,
        layoutName: String,
        packageName: String
) {
    val (projectData, srcOut, resOut) = moduleData
    val ktOrJavaExt = projectData.language.extension

    generateManifest(
            moduleData = moduleData,
            activityClass = "${activityClass}Activity",
            packageName = packageName,
            isLauncher = true,
            hasNoActionBar = false,
            generateActivityTitle = true
    )

    val mvvmActivity = guideAcitivityKt(projectData.applicationPackage, activityClass, packageName)
    // 保存Activity
    save(mvvmActivity, srcOut.resolve("${activityClass}Activity.${ktOrJavaExt}"))
    // 保存xml
    save(guideActivityXml(packageName, activityClass), resOut.resolve("layout/${layoutName}.xml"))
}